<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglibs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<s:if test="@org.springside.modules.security.springsecurity.SpringSecurityUtils@getCurrentUserName() == 'anonymousUser'">
	<s:include value="/admin/login.jsp" />
</s:if> <s:else>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加公告</title>
<style type="text/css">
/*manage********************************/
.main .manage{
  margin:15px;
  border: 1px solid #ccc;
}
.manage .manage_massage{
  margin: 0 185px;
}
.manage .manage_massage .manage_classify{
  position: relative;
  margin-top: 30px;
}
.manage .manage_massage label{
  position: absolute;
  left: -136px;
  float: left;
  display: inline-block;
  width: 120px;
  line-height: 27px;
  text-align: right;
  font-size: 16px;
  margin-right: 5px;
}
.manage .manage_massage .title{
  height: 32px;
  padding: 8px 10px;
  width: 100%;
  border: 1px solid #ccc;
} 
.manage .manage_massage .manage_select{
  width: 186px;
  height: 30px;
}
.manage .manage_massage .add_pic{
  float: left;
  width: 644px;
  height: 22px;
  padding: 3px 10px;
  margin-right: 15px;
  border: 1px solid #ccc;
}
.manage .manage_massage .add_file{
  display: inline-block;
  width: 84px;
  height: 35px;background: url(${ctx }/images/body_button_add_p.png) no-repeat;
}
.manage .manage_massage .add_file:hover{
  background: url(${ctx }/images/body_button_add_active_p.png) no-repeat;
}
.manage .manage_massage .textarea{
  width: 100%;
  height:374px;
  padding: 10px;
}
.manage .manage_massage .add_file_textarea{
  float: right;
  margin:14px 0 33px;
  height: 35px;
  background: url(${ctx }/images/body_button_handup_p.png) no-repeat;
}
.manage .manage_massage .add_file_textarea:hover{
  background: url(${ctx }/images/body_button_hangup_active.png) no-repeat;
}
</style>
<link href="${ctx }/css/public.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="${ctx }/kindeditor-4.1.9/themes/simple/simple.css" />
<script charset="utf-8" src="${ctx }/kindeditor-4.1.9/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx }/kindeditor-4.1.9/lang/zh_CN.js"></script>
<script type="text/javascript" src="${ctx }/My97DatePicker/WdatePicker.js"></script>

<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="entity.details"]', {
			       cssPath : '${ctx}/kindeditor-4.1.9/plugins/code/prettify.css',
				uploadJson :  '${ctx}/kindeditor-4.1.9/jsp/upload_json.jsp',  
				themeType : 'simple',
				fillDescAfterUploadImage:true,
				items:   [ 'source', '|', 'undo', 'redo', '|', 'preview', 'cut', 'copy', 'paste',
        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'hr', 'link', 'unlink', '|','filemanager','insertfile','image'] ,
				fileManagerJson : '${ctx}/kindeditor-4.1.9/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['article'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['ar7ticle'].submit();
					});
				}
			});
		});
		</script>
</head>

<body>

	<div class="main">
		<div class="tip">
      <span>所在位置 :</span>
      <span class="current_position">通知公告编辑</span>   
    </div>
    <div class="manage">
      <form action="${ctx }/admin/announcement-admin!save.action?id=${id}" method="post">
      <input type="hidden" name="entity.shownew" id="latestReading"/>
		<input type="hidden" name="entity.showred" id="latestAnnouncement"/>
        <div class="manage_massage clearfix">
          <div class="manage_classify">
            <label for="title">标题 :</label>
            <input type="text" class="title" id="title" maxlength="50" name="entity.title" value="${entity.title}"/>
          </div>
              <div class="manage_classify clearfix">
              <label for="time">发布时间 :</label>
              <input type="text" id="time" name="entity.editTime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  class="title" value="${entity.editTime}${time}"/>
          </div>
           <input type="checkbox" id="reading" <s:if test="entity.shownew==1"> checked="checked"</s:if>  />是否标示new
						<input type="checkbox" id="announcement" <s:if test="entity.showred==1"> checked="checked"</s:if> />字体是否变红
          <div class="manage_classify clearfix">
            <label for="textarea">详细内容:</label>
            <textarea id="textarea" class="textarea" name="entity.details">${entity.details}</textarea>
          </div>
          <a class="add_file add_file_textarea"></a>
          <input type="submit" id="submit" style="display:none;" />
        </div>
      </form>
    </div>
	</div>
  <script type="text/javascript" src="${ctx }/js/public.js"></script>
  <script type="text/javascript">
    //点击提交按钮，表单提交 这里需要一个接口上传数据
 
    var add_file_textarea = newdom.getElementsByClass("add_file_textarea")[0],
        submit = newdom.$("submit");
    var time=document.getElementById("time");
    add_file_textarea.onclick = function(){

      var arr = is_empty(["title"],["标题"]),//传id字符串
        len_arr = arr.length;
        var announcementCheckbox = document.getElementById("announcement");
		var readingCheckbox = document.getElementById("reading");
		var announcementInput = document.getElementById("latestAnnouncement");
		var readingInput = document.getElementById("latestReading");
		if(announcementCheckbox.checked){
			announcementInput.value="1";
		}else{
			announcementInput.value="0";
		}
		if(readingCheckbox.checked){
			readingInput.value="1";
		}else{
			readingInput.value="0";
		}
      if(len_arr != 0){
          for (var i = 0; i < len_arr; i++) {
            alert(arr[i] + "不能为空");
            return false;
          };
        }
      if(time.value==""){
      	alert("发布时间不能为空！");
      return false;}
        if(editor.isEmpty()){
			alert("正文不能为空！");
			return false;
		}
        
      else{
        submit.click();
      }

    }

  </script>
</body>
</html>
</s:else>